﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Menu
{
    /// <summary>
    /// Interaction logic for Deal.xaml
    /// </summary>
    public partial class Deal : Page
    { 
        public static DependencyProperty IDCheckingStatusProperty = DependencyProperty.Register("IDCheckingStatus", typeof(string), typeof(Deal));
        public string IDCheckingStatus
        {
            get { return (string)GetValue(IDCheckingStatusProperty); }
            set { SetValue(IDCheckingStatusProperty, value); }
        }
        public static TinyCinema.Bussiness.Menu.Deal dataContext = new TinyCinema.Bussiness.Menu.Deal();
        public Deal()
        {
            InitializeComponent();
            DataContext = dataContext;
            (DataContext as Bussiness.Menu.Deal).Messenger.ResetAll();
            (DataContext as Bussiness.Menu.Deal).Messenger.Register<Bussiness.Menu.Message.DeleteConfirmation>(this, ShowMessageBox3);
            (DataContext as Bussiness.Menu.Deal).Messenger.Register<Bussiness.Menu.Message.CustomerIDFound>(this, (s)=>
            {
                IDCheckingStatus = (App.Current.FindResource("langMsgIDCheckingYes") as String);
            }
        );
            (DataContext as Bussiness.Menu.Deal).Messenger.Register<Bussiness.Menu.Message.CustomerIDNotFound>(this, (s) =>
            {
                IDCheckingStatus = (App.Current.FindResource("langMsgIDCheckingNo") as String);
            });
            (DataContext as Bussiness.Menu.Deal).Messenger.Register<Bussiness.Menu.Message.PayConfirmation>(this, (s) =>
            {
                s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgDealPay") as String), "", MessageBoxButton.YesNo);
            });
            (DataContext as Bussiness.Menu.Deal).Messenger.Register<Bussiness.Menu.Message.PayConfirmationOK>(this, (s) =>
            {
                (new MenuOrder()).ShowDialog();
            });

        }
        void ShowMessageBox3(Bussiness.Menu.Message.DeleteConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgDealCancel") as String), "", MessageBoxButton.YesNo);
        }
        
        private void DataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            (DataContext as Bussiness.Menu.Deal).ValueCount();
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            (DataContext as Bussiness.Menu.Deal).CheckCustomerIDCommand.Execute((sender as TextBox).Text);
        } 

    }
}
